package com.immunology.servlets;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.immunology.model.MappingPages;
import com.immunology.service.SyndromeService;

public class AddSyndromeServlet extends HttpServlet{
	private static final long serialVersionUID = 1L;

	public AddSyndromeServlet() {
		super();
	}

	protected void doGet(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {
		getServletContext().getRequestDispatcher(MappingPages.ADD_SYNDROME_JSP)
				.forward(request, response);
	}

	protected void doPost(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {
		request.setCharacterEncoding("utf-8");
		String syndrome = request.getParameter("syndrome");

		SyndromeService syndromeService = SyndromeService.getInstance();
		syndromeService.insert(syndrome);

		request.getRequestDispatcher(MappingPages.ADD_SYNDROME_JSP).forward(
				request, response);
	}

}
